$(document).ready(function(){
	$('#showDeptDown').click(function (){
		$('#twolinedept').removeClass('noned');
		$('#threelinedept').removeClass('noned');
		$('#twolinedept').addClass('blockd');
		$('#threelinedept').addClass('blockd');
		$(this).removeClass('blockd');
		$(this).addClass('noned');
		$('#showDeptUp').removeClass('noned');
		$('#showDeptUp').addClass('blockd');
	});
	$('#showDeptUp').click(function (){
		$('#twolinedept').removeClass('blockd');
		$('#threelinedept').removeClass('blockd');
		$('#twolinedept').addClass('noned');
		$('#threelinedept').addClass('noned');
		$(this).removeClass('blockd');
		$(this).addClass('noned');
		$('#showDeptDown').removeClass('noned');
		$('#showDeptDown').addClass('blockd');
	});
	$('#telLink').click(function () {
		var values = getvalues();
		telPopup(values);
		window.setTimeout(function(){
		$("#telp").css("display","none");
		$("#subtelp").css("display","none");},3000);

	});
	$('#telImage').click(function () {
		var values = getvalues();
		telPopup(values);
		window.setTimeout(function(){
		$("#telp").css("display","none");
		$("#subtelp").css("display","none");},3000);
	});
	$('#smsLink').click(function () {
		var values = getvalues();
		alert("informIncidentNew");
		//alert(values.toString());
		smsPopup(values);
		
	});
	$('#smsImage').click(function () {
		var values = getvalues();
		smsPopup(values);
	});
	$('#faxLink').click(function () {
		var values = getvalues();
		//alert(values.toString());
		faxPopup(values);
		
	});
	$('#faxImage').click(function () {
		var values = getvalues();
		faxPopup(values);
	});
	$('#videoLink').click(function () {
    	 window.open('videoView.jsp','video','width=960,height=750');
	});
	$('#videoImage').click(function () {
		window.open('videoView.jsp','video','width=960,height=750');
	});
	$('#pdaLink').click(function () {
		var values = getvalues();
		pdaPopup(values);
	});
	$('#pdaImage').click(function () {
		var values = getvalues();
		pdaPopup(values);
	});
	$("input[type='checkbox']").click(function(){
//alert(this.checked);
		$(this).parent().find("input[type='checkbox']").attr("checked",$(this).attr("checked"));
		
		return true;
	});
});

function getvalues() {
	var valueobjects =$(":checkbox:checked"); 
	//alert(valueobjects.length);
	var valuesarry = new Array(valueobjects.length);
	for(var i = 0;i < valueobjects.length; i++ ){
			//alert($(valueobjects[i]).val());
			var value =$(valueobjects[i]).val();
		if(value !='on'){
			valuesarry.push(value);
		}
	}
	return valuesarry;
}

function telPopup(values){
	var temp = new Array(values.length);
	for(var i=0;i<values.length;i++){
		var value=values.pop();
		if(value!=null){
			temp.push(value);
		}
	}
	//alert(temp.toString());
	var strHTML="<div id='telp' class='faqbg'></div>";
	strHTML+="<div id='subtelp' class='faqdiv' style='display:none';width:'50px'>";
	strHTML+="<div class='form'>这里是提示信息！！</div></div>";
	$("body").append(strHTML);
	var str = "<div><table  border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td align='center'><img src='../images/tel.gif'></td></tr><tr>";
	for(var i=0;i<temp.length+1;i++){
		
		var value=temp.pop();
		if(value!=null)
			str+="<tr><td align='center'>"+value+"已拨通....</td></tr>";
	}
		
	str+="</tr></table></div>";

		$(".form").html(str);
		$("#telp").css({display:"block",height:$(document).height()});
		var yscroll =document.documentElement.scrollTop;
		$("#subtelp").css("top","100px");
		$("#subtelp").css("display","block");
		document.documentElement.scrollTop=0;
}

function smsPopup(values){
	var recieve = "";
	var temp = new Array(values.length);
	
	//alert(recieve);
	var strHTML="<div id='smsp' class='faqbg'></div>";
	strHTML+="<div id='subsmsp' class='txtfaqdiv' style='display:none'>";
	strHTML+="<h2>短信编辑<a href='#' class='close'>关闭</a></h2>";
	strHTML+="<div class='form'>这里是提示信息！！</div></div>";
	$("body").append(strHTML);
	var str = "<table  border='0' cellspacing='0' cellpadding='0'><tr><td valign='top' align='right'>收信人：</td><td><select size='5' style='width:340px'>";
	//<input type='text' id='cllc' value='"+recieve+"' readonly='readonly' style='width:240'/></td></tr>";
	for(var i=0;i<values.length;i++){
		var value=values.pop();
		if(value!=null)
			str+="<option>"+value+"</option>"
		temp.push(value);
	}
	str +="</select><tr><td valign='top'>短信内容： </td><td><textarea id='advice' rows='10' cols='40'></textarea></td></tr>";
	
	str+="<tr><td colspan='2' align='center'><input type='button' id='btnAdd' value='短信发送' style='margin:0 auto; margin-top:15px' /></td></tr>";

		$(".form").html(str);
		$("#smsp").css({display:"block",height:$(document).height()});
		var yscroll =document.documentElement.scrollTop;
		$("#subsmsp").css("top","100px");
		$("#subsmsp").css("display","block");
		document.documentElement.scrollTop=0;
	$(".close").click(function(){
		$("#smsp").css("display","none");
		$("#subsmsp").css("display","none");
	});
	$("#btnAdd").click(function(){
		$("#smsp").css("display","none");
		$("#subsmsp").css("display","none");
		groupSend(temp);
		window.setTimeout(function(){
		$("#gsp").css("display","none");
		$("#subgsp").css("display","none");
	},3000);
	});
}

function faxPopup(values){
	var recieve = "";
	var temp = new Array(values.length);
	
	//alert(recieve);
	var strHTML="<div id='faxp' class='faqbg'></div>";
	strHTML+="<div id='subfaxp' class='txtfaqdiv' style='display:none'>";
	strHTML+="<h2>传真编辑<a href='#' class='close'>关闭</a></h2>";
	strHTML+="<div class='form'>这里是提示信息！！</div></div>";
	$("body").append(strHTML);
	var str = "<table  border='0' cellspacing='0' cellpadding='0'><tr><td valign='top' align='right'>收传真人：</td><td><select size='5' style='width:340px'>";
	//<input type='text' id='cllc' value='"+recieve+"' readonly='readonly' style='width:240'/></td></tr>";
	for(var i=0;i<values.length;i++){
		var value=values.pop();
		if(value!=null)
			str+="<option>"+value+"</option>"
		temp.push(value);
	}
	str +="</select><tr><td valign='top'>传真内容： </td><td><textarea id='advice' rows='10' cols='40'></textarea></td></tr>";
	
	str+="<tr><td colspan='2' align='center'><input type='button' id='btnAdd' value='传真发送' style='margin:0 auto; margin-top:15px' /></td></tr>";

		$(".form").html(str);
		$("#faxp").css({display:"block",height:$(document).height()});
		var yscroll =document.documentElement.scrollTop;
		$("#subfaxp").css("top","100px");
		$("#subfaxp").css("display","block");
		document.documentElement.scrollTop=0;
	$(".close").click(function(){
		$("#faxp").css("display","none");
		$("#subfaxp").css("display","none");
	});
	$("#btnAdd").click(function(){
		$("#faxp").css("display","none");
		$("#subfaxp").css("display","none");
		groupSend(temp);
		window.setTimeout(function(){
		$("#gsp").css("display","none");
		$("#subgsp").css("display","none");
	},3000);
	});
}

function groupSend(values){
	//alert(values.toString());
	var strHTML="<div id='gsp' class='faqbg'></div>";
	strHTML+="<div id='subgsp' class='faqdiv' style='display:none'>";
	//strHTML+="<h2>短信编辑<a href='#' class='close'>关闭</a></h2>";
	strHTML+="<div class='form'>这里是提示信息！！</div></div>";
	$("body").append(strHTML);
	
	var str = "<table  border='0' cellspacing='0' cellpadding='0'>"
	//alert(str);
	for(var i=0;i<values.length;i++){
		var value=values.pop();
		//alert(str);
		if(value!=null)
			str+="<tr><td>"+value+"已发送。。。。。。</td></tr>";
	}
	
	//str +="<tr><td valign='top'>请输入短信内容： </td><td><textarea id='advice' rows='2' cols='20'></textarea></td></tr>";
	str+="</table>"
	//str+="<tr><td cols='2'><input type='button' id='btnAdd' value='短信发送' style='margin:0 auto; margin-top:15px' /></td></tr>";
		$(".form").html(str);
		$("#gsp").css({display:"block",height:$(document).height()});
		var yscroll =document.documentElement.scrollTop;
		$("#subgsp").css("top","100px");
		$("#subgsp").css("display","block");
		document.documentElement.scrollTop=0;
	
}

function pdaPopup(values){
	var recieve = "";
	var temp = new Array(values.length);
	
	var strHTML="<div id='pdap' class='faqbg'></div>";
	strHTML+="<div id='subpdap' class='txtfaqdiv' style='display:none'>";
	strHTML+="<h2>PDA信息编辑<a href='#' class='close'>关闭</a></h2>";
	strHTML+="<div class='form'>这里是提示信息！！</div></div>";
	$("body").append(strHTML);
	var str = "<table  border='0' cellspacing='0' cellpadding='0'><tr><td valign='top' align='right'>收信人：</td><td><select size='3' style='width:340px'>";
	//<input type='text' id='cllc' value='"+recieve+"' readonly='readonly' style='width:240'/></td></tr>";
	for(var i=0;i<values.length;i++){
		var value=values.pop();
		if(value!=null)
			str+="<option>"+value+"</option>"
		temp.push(value);
	}
	str +="</select><tr><td valign='top'>PDA信息内容： </td><td><textarea id='advice' rows='10' cols='40'></textarea></td></tr>";
	
	str+="<tr><td colspan='2'><input type='button' id='btnAdd' value='PDA信息发送' style='margin:0 auto; margin-top:15px' /></td></tr>";

		$(".form").html(str);
		$("#pdap").css({display:"block",height:$(document).height()});
		var yscroll =document.documentElement.scrollTop;
		$("#subpdap").css("top","100px");
		$("#subpdap").css("display","block");
		document.documentElement.scrollTop=0;
	$(".close").click(function(){
		$("#pdap").css("display","none");
		$("#subpdap").css("display","none");
	});
	$("#btnAdd").click(function(){
		$("#pdap").css("display","none");
		$("#subpdap").css("display","none");
		groupSend(temp);
		window.setTimeout(function(){
		$("#gsp").css("display","none");
		$("#subgsp").css("display","none");
		},3000);
	});
}